package com.daxt.common.exception;

import com.daxt.common.result.ResultCode;
import org.springframework.util.StringUtils;
import sun.misc.MessageUtils;

public class BaseException extends RuntimeException {
//public class BaseException extends Exception {

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    private String code;

    private Object msg;


    public BaseException() {
        super();
    }

//    public BaseException(String code, Object msg) {
//        super();
//        this.code = code;
//        this.msg = msg;
//    }


    /**
     * 错误消息
     */
    private String defaultMessage;

    public BaseException(String code, String msg) {
        this.code = code;
        this.defaultMessage = msg;
        this.msg = msg;
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Object getMsg() {
        return msg;
    }

    public void setMsg(Object msg) {
        this.msg = msg;
    }

    public BaseException(ResultCode resultEnum) {
        super(resultEnum.getMes());
        this.code = resultEnum.getCode();
    }

    @Override
    public String getMessage() {
        String message = null;
        if (message == null) {
            message = defaultMessage;
        }
        return message;
    }
}
